package cn.sh.library.gmwx.sparql.impl;

import java.util.List;
import java.util.Map;

import org.ontoware.rdf2go.model.Model;
import org.ontoware.rdf2go.model.QueryResultTable;
import org.springframework.stereotype.Repository;

import cn.sh.library.gmwx.annotation.GraphDefine;
import cn.sh.library.gmwx.base.Constant;
import cn.sh.library.gmwx.common.ModelManager;
import cn.sh.library.gmwx.dao.impl.BaseDaoImpl;
import cn.sh.library.gmwx.sparql.ItemSparql;
import cn.sh.library.gmwx.sparql.RdfQuery;
import cn.sh.library.gmwx.utils.RDFUtils;

@Repository
@GraphDefine(name = Constant.GRAPH_ITEM)
public class ItemSparqlImpl extends BaseDaoImpl implements ItemSparql {
    @Override
    public List<Map<String, String>> getInstanceItems(String instance_uri) {
        Model model_op = ModelManager.get(model);
        QueryResultTable rst = model_op.sparqlSelect(RdfQuery.RDF_QUERY_INSTANCE_ITEMS.toString(instance_uri));
        return RDFUtils.transformQueryResultTable(rst);
    }
    
    @Override
    public List<Map<String, String>> getIdentifier(String instance_uri) {
        Model model_op = ModelManager.get(model);
        QueryResultTable rst = model_op.sparqlSelect(RdfQuery.RDF_QUERY_INSTANCE_ITEMS_IDENTIFIER.toString(instance_uri));
        return RDFUtils.transformQueryResultTable(rst);
    }
}
